package com.market.member.service.auth;

import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.block.db.entity.MemberAuthConfigInfo;
import com.block.db.entity.MemberAuthRecordInfo;
import com.market.member.enums.AuthStatusEnum;
import com.market.member.model.dto.AuthHandleDTO;
import com.market.member.model.dto.AuthQueryDTO;
import com.market.member.model.dto.AuthRequestDTO;
import com.market.member.model.result.AuthHandleResult;
import com.market.member.model.result.AuthQueryResult;
import com.market.member.model.result.AuthRequestResult;
import com.market.member.service.IAuthService;
import org.springframework.stereotype.Service;

@Service
public class DefaultAuthService implements IAuthService {

    @Override
    public AuthHandleResult handleAuthInfo(MemberAuthConfigInfo authConfigInfo, AuthHandleDTO authHandleDTO) {

        AuthHandleResult authHandleResult = new AuthHandleResult();
        authHandleResult.setAuthStatus(AuthStatusEnum.SUCCESS.getValue());
        authHandleResult.setCode("200");
        authHandleResult.setMessage("成功");
        authHandleResult.setParamInfo("成功");
        authHandleResult.setResultInfo("成功");

        return authHandleResult;
    }

    @Override
    public AuthRequestResult getAuthConfigInfo(AuthRequestDTO authRequestDTO, MemberAuthConfigInfo authConfigInfo) {

        AuthRequestResult authRequestResult = new AuthRequestResult();

        authRequestResult.setOrderNo(authRequestResult.getOrderNo());
        authRequestResult.setSuccess(true);
        String outOrderNo = RandomUtil.randomString(28);
        authRequestResult.setOutOrderNo(outOrderNo);
        authRequestResult.setResultInfo(outOrderNo);
        authRequestResult.setResultData(outOrderNo);

        return authRequestResult;
    }

    @Override
    public AuthQueryResult queryAuthVerifyResult(AuthQueryDTO authQueryDTO, MemberAuthConfigInfo authConfigInfo) {

        AuthQueryResult authQueryResult  = new AuthQueryResult();
        authQueryResult.setSuccess(true);
        authQueryResult.setAuthStatus(AuthStatusEnum.SUCCESS.getValue());
        authQueryResult.setRealname("网友钱");
        authQueryResult.setIdCard(RandomUtil.randomNumbers(18));
        authQueryResult.setIdCardFrontUrl("https://baidu.com");
        authQueryResult.setIdCardBackUrl("https://jd.com");
        authQueryResult.setPersonImageUrl("https://taobao.com");
        authQueryResult.setResultInfo(JSON.toJSONString(authQueryResult));

        return authQueryResult;
    }
}
